package wan.moneybook.dao;

import java.sql.SQLException;
import java.util.Map;
import java.util.TreeMap;

import wan.moneybook.bean.Type;

public class CardDao extends Dao {

	@SuppressWarnings("unchecked")
	public TreeMap<Integer,String> getAllCard() {
		try {
			Map map = sqlMap.queryForMap("getAllCard", null, "type", "name");
			return new TreeMap(map);
		} catch (SQLException e) {
			throw new RuntimeException("Error DAO class. Cause:" + e);
		}
	}

	public void addCard(Type type) {
		try {
			sqlMap.insert("addCard", type);
		} catch (SQLException e) {
			throw new RuntimeException("Error DAO class. Cause:" + e);
		}
	}

	public void removeAllCard() {
		try {
			sqlMap.delete("removeAllCard");
		} catch (SQLException e) {
			throw new RuntimeException("Error DAO class. Cause:" + e);
		}
	}
}
